<template><!--已驳回药方-->
  <div class="prescriptionCManageC">
    <!-- 搜索条件 -->
    <div class="filter-container">
      <el-input placeholder="处方编号" v-model="searchNumber"></el-input>
      <el-input placeholder="患者姓名" v-model="searchName"></el-input>
      <el-button type="primary" icon="search" @click="search">搜索</el-button>
      <el-button type="primary" icon="view" @click="showAll">显示全部</el-button>
    </div>
    <el-table :data="prescriptionC">
      <el-table-column type="expand">
        <template scope="props">
          <el-form label-position="left" inline class="form-expand">
            <el-form-item label="科别：">
              <span>{{ props.row.disease }}</span>
            </el-form-item>
            <el-form-item label="医生：">
              <span>{{ props.row.doctor }}</span>
            </el-form-item>
            <el-form-item label="开具日期：">
              <span>{{ props.row.date }}</span>
            </el-form-item>
            <hr class="hr">
            <el-form-item label="临床诊断：" class="symptoms">
              <span>{{ props.row.symptoms }}</span>
            </el-form-item>
            <hr class="hr">
            <h5 class="prescriptionC-title">R</h5>
            <template>
              <el-table :data="props.row.patientcountList" style="width: 80%; margin: 0 auto;">
                <el-table-column prop="" label="药品分类" width="100">
                </el-table-column>
                <el-table-column prop="drugName" label="药品名称" width="200">
                </el-table-column>
                <el-table-column prop="quantity" label="用量（件/克）" width="180">
                </el-table-column>
                <el-table-column prop="remark" label="用法" width="260">
                </el-table-column>
              </el-table>
            </template>
            <!-- <el-form-item label="备注：" class="Rp">
              <span>{{ props.row.usage }}</span>
            </el-form-item> -->
          </el-form>
        </template>
      </el-table-column>
      <el-table-column label="编号" prop="number">
      </el-table-column>
      <el-table-column label="患者姓名" prop="name">
      </el-table-column>
      <el-table-column label="性别" prop="sex">
      </el-table-column>
      <el-table-column label="年龄" prop="age">
      </el-table-column>
      <el-table-column label="地址" prop="position">
      </el-table-column>
      <el-table-column label="联系方式" prop="phone">
      </el-table-column>
      <el-table-column label="审核药师" prop="pharmacist">
      </el-table-column>
      <el-table-column label="已处理" prop="waitingNumber" width="100">
       <template slot-scope="scope">
            {{ scope.row.waitingNumber == '0' ? '已驳回' : '已出药' }}
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script type="text/ecmascript-6">
  import {
    api
  } from '../../../global/api.js';
  export default {
    data() {
      return {
        prescriptionC: [],
        intendedprescription: [],
        drugs: [],
        searchNumber: '',
        searchName: '',
      };
    },
    mounted() { //初始化
      let that = this;
      let apilogin = "http://localhost:8088/selectWaitingNumber0"
      this.$http.get(apilogin).then((response) => {
          console.log(response.body.data)
          that.prescriptionC = response.body.data;
          that.intendedprescription = response.body.data;
      }, response => {
        this.$message({
          message: '数据请求失败',
          type: 'error'
        });
      });

    },
    methods: {
      // 搜索
      search() {
        let that = this;
        if (this.searchNumber === '' || this.searchNumber === null) {
          this.searchNumber = ' ';
        }
        if (this.searchName === '' || this.searchName === null) {
          this.searchName = ' ';
        }
        let apilogin = "http://localhost:8088/getNameAndNumber/"+this.searchNumber+"/"+this.searchName
        this.$http.get(apilogin).then((response) => {
            console.log(response.body.data)
            that.prescriptionC = response.body.data;
        }, response => {
          this.$message({
            message: '数据请求失败',
            type: 'error'
          });
        });
      },
      // 显示全部数据
      showAll() {
        this.prescriptionC = this.intendedprescription;
        this.searchNumber = '';
        this.searchName = '';
      },
    }
  };
</script>

<style>
  .prescriptionCManageC .filter-container {
    padding-bottom: 30px;
  }

  .el-input {
    width: 200px;
  }

  .prescriptionCManageC .form-expand {
    /* background: #99FF66 */
    width: 80%;
    margin: 0 auto;
  }

  .el-form-item {
    width: 29%;
    display: inline-block;
    margin-left: 20px;
  }

  .symptoms {
    width: 100%;
  }

  .Rp {
    width: 80%;
    margin-left: 10%;
  }

  .hr {
    margin-top: -25px;
    border-top: 1px solid #4A7C32;
  }

  .prescriptionC-title {
    font-size: 26px;
    margin-left: 20px;
  }

  .prescriptionCManageC .form-expand .el-form-item span {
    display: block;
    font-size: 15px;
    font-weight: bold;
  }
</style>
